package com.gin.kotlin.no_gay_alliance.fragment.topiclist

import android.content.Context
import android.os.Bundle
import com.gin.kotlin.no_gay_alliance.activity.TopicListActivity
import com.gin.kotlin.no_gay_alliance.activity.TopicListActivity.Companion.KEY_ARGUMENT
import com.gin.kotlin.no_gay_alliance.argument.TopicListArgument
import com.gin.kotlin.no_gay_alliance.databinding.FragmentTopicListUserSearchBinding

class UserSearchFragment : AbstractTopicListFragment<FragmentTopicListUserSearchBinding>() {
    companion object {
        fun newInstance(argument: TopicListArgument) = UserSearchFragment().also { it.arguments = Bundle().also { b -> b.putParcelable(KEY_ARGUMENT, argument) } }

        /**
         * 启动活动
         */
        fun startActivityTopic(
            context: Context,
            authorUid: Long,
            forumId: Long? = null,
            page: Int? = null,
            recommendOnly: Boolean = false,
            title: String? = null,
        ) = TopicListActivity.startActivity(
            context, TopicListArgument(
                TopicListArgument.Type.USER_SEARCH,
                authorUid = authorUid,
                forumId = forumId,
                recommendOnly = recommendOnly,
                page = page,
                title = title
            )
        )

        fun startActivityReply(
            context: Context,
            authorUid: Long,
            forumId: Long? = null,
            page: Int? = null,
            title: String? = null,
        ) = TopicListActivity.startActivity(
            context, TopicListArgument(
                TopicListArgument.Type.USER_SEARCH,
                authorUid = authorUid,
                forumId = forumId,
                page = page,
                searchReply = true,
                title = title
            )
        )
    }
}